do
  function setType(parent)
    parent:setType("gunner");
  end
  
  
  function update(parent)
    
    local x = parent:getMaxEnergy()
    local x2 = parent:getEnergy();
  
    local y = x2/x;
    if y < .2 then
      parent:rest(100,1);
    end
    
  end
  
  setType();
  update();
end